public class Prime_number {
    public static void main(String[] args) {
        int count=0;
        for(int i = 1;i <= 20000;i++) {
            for (int j = i; j >= 1; j--) {
                if ((i % j == 0) && j != 1 && i != j)
                    break;
                if(j==1){
                   count++;
                   System.out.print(i+" ");
                       if(count%5==0)
                           System.out.println();
               }
            }
        }
    }
}